package top.huhuiyu.teachproject.controller.test;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.huhuiyu.teachproject.base.BaseResult;
import top.huhuiyu.teachproject.entity.AuthInfo;
import top.huhuiyu.teachproject.utils.AuthInfoUtils;

@RestController
@RequestMapping("/test/auth")
public class AuthTestController {

  @GetMapping("/admin")
  public BaseResult admin() {
    AuthInfo authInfo = AuthInfoUtils.authInfo();
    return BaseResult.ok(String.format("管理员：%s", authInfo.getUserId()));
  }

  @GetMapping("/user")
  public BaseResult user() {
    AuthInfo authInfo = AuthInfoUtils.authInfo();
    return BaseResult.ok(String.format("普通用户：%s", authInfo.getUserId()));
  }

  @GetMapping("/adminOrUser")
  public BaseResult adminOrUser() {
    AuthInfo authInfo = AuthInfoUtils.authInfo();
    return BaseResult.ok(String.format("用户：%s", authInfo.getUserId()));
  }

}
